<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!doctype html>
<html lang="zh-CN">
<head>
<title>每日渠道数据</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="static/jquery-easyui-1.4.4/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="static/jquery-easyui-1.4.4/themes/icon.css">
<style type="text/css">
.expired {
	color: red;
}

.expireing {
	color: blue;
}

.attentionPlase {
	padding-left: 20px;
	color: red;
	font-size: 20px;
}

.easyui-datebox2 {
	width: 100px;
}

.textbox {
	border-radius: 0px;
}
</style>
</head>
<body class="easyui-layout">
	<div data-options="region:'center',split:true" style="background-color: #eee; border: 0px;">
		<table id="tt" class="easyui-datagrid" style="width: 100%; height: 100%;" data-options="rownumbers:true,singleSelect:true,url:'query.htm?listId=SLAVE_USER.findDailyChannelData',method:'post',toolbar:toolbar,pagination:false,rownumbers:true,sortName:'reg_date',sortOrder:'asc',fitColumns:true">
			<thead>
				<tr>
					<th field="date_str">日期</th>
					<th field="channel">渠道号</th>
					<th field="new_reg_count">注册数</th>
					<th field="new_bid_count" align="right">新增交易用户数</th>
					<th field="new_bid_amount" data-options="formatter:cellProfit" align="right">新增投资金额</th>
					<th field="bid_count" align="right">总交易用户数</th>
					<th field="sum_amount" data-options="formatter:cellProfit" align="right">总投资金额</th>
				</tr>
			</thead>
		</table>
	</div>
	<div id="conditionDiv" style="margin-left: 20px;">
		日期<input id="beginDate" class="easyui-datebox easyui-datebox2" />~<input id="endDate" class="easyui-datebox easyui-datebox2" />
		<button id="btnQuery">查询</button>
		<button id="btnExport">导出</button>
		<span style="color: red;">（查询和导出的时间区间不要超过40天，查询时间为空时默认查询一周内的数据）</span>
	</div>

	<script type="text/javascript" src="static/jquery-1.11.0.js"></script>
	<script type="text/javascript" src="static/comm.js"></script>
	<script type="text/javascript" src="static/jquery-easyui-1.4.4/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="static/jquery-easyui-1.4.4/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript">
		var toolbar = [];
		
		function cellProfit(val, row) {
			return val.toFixed(2);
		}

		$(function() {
			$('#conditionDiv').appendTo($($(".datagrid-toolbar")[0]).find("tr"));

			$("#btnQuery").click(function() {
				var param = QueryCondition.get();
				if(param.beginDate && param.endDate){
					var d1 = Date.parse(param.beginDate);
					var d2 = Date.parse(param.endDate);
					if(parseInt((d2 - d1) / (24 * 60 * 60 * 1000)) > 40) {
						return;
					}
				}else if(param.beginDate){
					param.endDate= param.beginDate;
				} else if(param.endDate) {
					param.beginDate = param.endDate;
				}
				$("#tt").datagrid("load", param);
			});
			//var attentionPlase = "请注意:8:00自动处理体验金标的,9:10自动处理定期标的,有不明白的联系技术部(王鸿雁18367156949)";
			//$(".datagrid-toolbar").find("td").append("<span class='attentionPlase'>" + attentionPlase + "</span>");
			
			$("#btnExport").click(function(){
				var param = QueryCondition.get(); 
				var href="exportexcel.htm?listId=SLAVE_USER.findDailyChannelData&rows=10000&excelname=每日渠道数据&";
				
				if(param.beginDate && param.endDate){
					var d1 = Date.parse(param.beginDate);
					var d2 = Date.parse(param.endDate);
					if(parseInt((d2 - d1) / (24 * 60 * 60 * 1000)) > 40) {
						return;
					}
					href+="&beginDate=" + param.beginDate+"&endDate=" + param.endDate;
				}else if(param.beginDate){
					href+="&beginDate=" + param.beginDate+"&endDate=" + param.beginDate;
				} else if(param.endDate) {
					href+="&beginDate=" + param.endDate+"&endDate=" + param.endDate;
				}
				window.open(href);
			});
		
		});

		var QueryCondition = {
			get : function() {
				var p = { 
					beginDate:$('#beginDate').datebox('getValue'),
					endDate:$('#endDate').datebox('getValue')
				}; 
				return p;
			}
		};
	</script>
</body>
</html>


